<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>2618. 检查是否是类的对象实例</title>
</head>

<body>

</body>

<script>
    /**
    * @param {*} obj
    * @param {*} classFunction
    * @return {boolean}
    */
    var checkIfInstanceOf = function (obj, classFunction) {
        if (obj === null || obj === undefined || typeof classFunction !== 'function') {
            return false;
        }
        while (obj.__proto__) {
            if (obj.__proto__ === classFunction.prototype) {
                return true;
            } else {
                obj = obj.__proto__;
            }
        }
        return false;
    };

    /**
     * checkIfInstanceOf(new Date(), Date); // true
     */
</script>

</html>